<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JS定时器</title>

    <script>
        window.onload = function () {
            let count = document.querySelector("#count");
            // for ( let i = 0; i < 10000; i++ ) {
            //     count.innerHTML = i;
            // }
            let i = 1;
            let timer = setInterval(()=>{
                count.innerHTML = i++;
                if (i === 11) {
                    clearInterval(timer);
                }
            }, 1000);
        };
    </script>
</head>
<body>
<h1 id="count"></h1>

</body>
</html>
